package com.bw.repair

import android.graphics.Color
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.blankj.utilcode.util.ColorUtils
import com.bw.repair.databinding.ItemRepairBinding
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import java.lang.ref.WeakReference

class RepairAdapter: BaseQuickAdapter<RepairBeanItem, BaseViewHolder>(R.layout.item_repair) {

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemRepairBinding>(viewHolder.itemView)
    }
    override fun convert(helper: BaseViewHolder, item: RepairBeanItem) {
        val binding = DataBindingUtil.getBinding<ItemRepairBinding>(helper.itemView)
        binding?.bean = item
        binding?.processingStatus?.apply {
            when(item!!.processingStatus){
                "待处理" ->{
                    setBackgroundResource(R.drawable.bg_dcl)
                    setTextColor(ColorUtils.getColor(R.color.yellow))
                }
                "处理中" ->{
                    setBackgroundResource(R.drawable.bg_clz)
                    setTextColor(Color.BLUE)
                }
                "已完成" ->{
                    setBackgroundResource(R.drawable.bg_ywc)
                    setTextColor(ColorUtils.getColor(R.color.green))
                }
            }
        }
    }


}